# __init__.py : 初始化文件，创建flask应用
from flask import Flask
from .views import blue
from .exts import *


def create_app():
    app = Flask(__name__)
    # 注册蓝图
    app.register_blueprint(blueprint=blue)
    app.debug = True
    # 配置端口
    # sqlite配置数据库
    db_uri = 'sqlite:///sqlite3.db'
    # Mysql数据库配置
    # db_uri = "mysql+pymysql://root:123456@localhost:3306/python"
    app.config['SQLALCHEMY_DATABASE_URI'] = db_uri  # 配置连接数据库路径DB_URI
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False  # 禁止对象追踪
    init_exts(app)
    return app
